package com.hst.capacity.infra.persistence.jpa.setting.station;

import com.hst.capacity.domain.model.entity.setting.station.StationEntity;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface StationRepository extends CrudRepository<StationEntity, String> {

    /**
     * 通过地区CODE查找运营市内汽车站
     * @param cityCode
     * @return
     */
    @Query("SELECT t FROM StationEntity t INNER JOIN ApplyStationEntity a ON t.idStation = a.idStation WHERE t.cityCode=:cityCode AND a.stationType IN (0,2)")
    List<StationEntity> getInnercityStationByCode(String cityCode);

    /**
     * 通过地区CODE查找运营城际汽车站
     * @param cityCode
     * @return
     */
    @Query("SELECT t FROM StationEntity t INNER JOIN ApplyStationEntity a ON t.idStation = a.idStation WHERE t.cityCode=:cityCode AND a.stationType IN (0,1)")
    List<StationEntity> findIntercityStationByCode(String cityCode);

    StationEntity findByIdStation(String idStation);

}
